package com.pattern.structure.composite;

/**
 * @author yangguanzan
 * @date 7/3/22
 * @description
 */
public abstract class CorpBase implements ICorp{
    private String name;

    private CorpBase parent;

    public CorpBase(String name) {
        this.name = name;
    }


    @Override
    public void operation() {

        System.out.println(this.name+" operation");
    }

    public String getName() {
        return name;
    }

    public CorpBase getParent() {
        return parent;
    }

    protected void setParent(CorpBase parent) {
        this.parent = parent;
    }

    public void preOperation(){
        this.operation();
        CorpBase parent=this.getParent();
        if(null!=parent){
            parent.preOperation();
        }
    }
}
